#ifndef SIMPLEQUERY_H
#define SIMPLEQUERY_H

#include <string>

using namespace std;

// forward declaration:
class From;
class Select;
class Where;
class GroupBy;
class BooleanExpression;

/*
    Class: SimpleQuery
    Represents an SQL Query with clauses: SELECT, FROM, WHERE, GROUP BY, HAVING.

    See also:
        Select
        From
        Where
        GroupBy
        Having
*/
class SimpleQuery
{
    /* Section: public */
    public:
        /*
            Destructor: Default destructor.
            Destroy the object.
        */
        virtual ~SimpleQuery();

        /*
            Constructor: Copy constructor
            Initializes the object as a copy from other SimpleQuery object.

            Parameters:
                other   -   Simple Query to copy from.
        */
        SimpleQuery(const SimpleQuery & other);

        /*
            Constructor: Parametrized constructor.
            Initializes the object with the given parameters:

            Parameters:
                select  -   Select clause of the SimpleQuery (Null by default).
                from    -   From clause of the SimpleQuery (Null by default).
                where   -   Where clause of the SimpleQuery (Null by default).
                groupby -   GroupBy clause of the SimpleQuery (Null by default).
                having  -   Having clause of the SimpleQuery (Null by default).

            See also:
                Select
                From
                Where
                GroupBy
                Having
        */
        SimpleQuery(Select * select = NULL, From * from = NULL, Where * where = NULL, GroupBy * groupby = NULL, BooleanExpression * having = NULL);

        /*
            Method: SetFrom
            Sets a From object as a SQL from clause.

            Parameters:
                from    -   From object to set.
        */
        void setFrom(From * from);

        /*
            Method: GetFrom
            Returns:
                From object that represents the SQL from clause of the query.
        */
        From * getFrom() const;

	    /*
            Method: SetSelect
            Sets a Select object as a SQL from clause.

            Parameters:
                select   -   select object to set.
        */
        void setSelect(Select * select);

        /*
            Method: GetSelect
            Returns:
                Select object that represents the SQL select clause of the query.
        */
        Select * getSelect() const;

	    /*
            Method: SetWhere
            Sets a Where object as a SQL where clause.

            Parameters:
                where    -   Where object to set.
        */
        void setWhere(Where * where);

        /*
            Method: GetFrom
            Returns:
                From object that represents the SQL from clause of the query.
        */
        Where * getWhere() const;

        /*
            Method: ToString
            Returns:
                A string representation of the SimpleQuery.
        */
        string toString();

        /*
            Method: clone
            Returns:
                A clone of this object.
        */
        SimpleQuery * clone();

    /* Section: private */
    private:
        /*
            Variable: select
            Type: Select *
            Select clause of the query.

            See also:
                Select
        */
        Select * select;

        /*
            Variable: from
            Type: From *
            From clause of the query.

            See also:
                From
        */
        From * from;

        /*
            Variable: where
            Type: Where *
            Where clause of the query.

            See also:
                Where
        */
	Where * where;

        /*
            Variable: groupby
            Type: GroupBy
            Group By clause of the query.

            See also:
                GroupBy
        */
        GroupBy * groupby;

        /*
            Variable: having
            Type: BooleanExpression
            Having clause of the query.
        */
        BooleanExpression * having;
};

#endif // SIMPLEQUERY_H
